package com.powersi;

import com.powercloud.rhea.rpc.core.reciver.servlet.RemotingServlet;
import com.powercloud.rhea.stat.RheaStatViewServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;

@SpringBootApplication
@ImportResource(locations= {"classpath*:spring/powercloud-rhea.xml"})
public class DemoProviderApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoProviderApplication.class, args);
    }

    //基础信息监控servlet
    @Bean
    //一定要返回ServletRegistrationBean
    public ServletRegistrationBean getRheaStatViewServletRegistrationBean() {
        //放入自己的Servlet对象实例
        ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean();
        servletRegistrationBean.setServlet(new RheaStatViewServlet());
        servletRegistrationBean.addInitParameter("loginUsername", "rhea");
        servletRegistrationBean.addInitParameter("loginPassword", "rhea");
        //访问路径值
        servletRegistrationBean.addUrlMappings("/powercloud/*");
        servletRegistrationBean.setName("PowerCloudStatView");
        return servletRegistrationBean;
    }

    //远程调用服务端servlet
    @Bean
    public ServletRegistrationBean getRemotingServletRegistrationBean() {
        ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean();
        servletRegistrationBean.setServlet(new RemotingServlet());
        servletRegistrationBean.addUrlMappings("/remoting.call");
        servletRegistrationBean.setName("remotingServlet");
        return servletRegistrationBean;
    }
}
